from datetime import datetime
from typing import Optional

from pydantic import BaseModel, ConfigDict, Field
from pydantic.alias_generators import to_camel

from module_admin.annotation.pydantic_annotation import as_query


class SmsRecordModel(BaseModel):
    """
    短信记录对应pydantic模型
    """

    model_config = ConfigDict(alias_generator=to_camel, from_attributes=True)

    id: Optional[int] = Field(default=None, description='主键')
    content: Optional[str] = Field(default=None, description='短信内容')
    create_time: Optional[datetime] = Field(default=None, description='创建时间')
    status: Optional[str] = Field(default=None, description='发送状态')
    receive_person: Optional[str] = Field(default=None, description='接收人')
    receive_phone: Optional[str] = Field(default=None, description='接收电话')
    err_reason: Optional[str] = Field(default=None, description='失败原因')
    del_flag: Optional[str] = Field(default=None, description='删除标志（0代表存在 2代表删除）')

class SmsRecordQueryModel(SmsRecordModel):
    """
    短信记录不分页查询模型
    """
    begin_time: Optional[str] = Field(default=None, description='开始时间')
    end_time: Optional[str] = Field(default=None, description='结束时间')

@as_query
class SmsRecordPageQueryModel(SmsRecordQueryModel):
    """
    短信记录分页查询模型
    """
    page_num: int = Field(default=1, description='当前页码')
    page_size: int = Field(default=10, description='每页记录数')

class AddSmsRecordModel(SmsRecordModel):
    """
    短信记录新增模型
    """
    pass
